package design.patterns.structural.proxy.dynamicproxy.cglib;

import net.sf.cglib.core.DebuggingClassWriter;
import net.sf.cglib.proxy.Enhancer;

/**
 * @author gjx
 * @version v1.0
 * @Description
 * @date 2019/4/4 11:16
 */
public class Test {
    public static void main(String[] args) {
//        System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY,"D:/proxy");

        //实例化一个增强器，也就是cglib中的一个class generator
        Enhancer enhancer = new Enhancer();

        //设置目标类
        enhancer.setSuperclass(People.class);
        //设置拦截对象
        enhancer.setCallback(new LawyerInterceptor());

        //创建代理对象
        People people = (People) enhancer.create();
        people.prosecute();
    }
}
